﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;

using Gift.WebApp;
using Gift.DAL;
using Gift.Model;
using System.IO;


public partial class cn_UserControl_footer : System.Web.UI.UserControl
{
    // Fields
    protected string basicSetXmlPath = "/cn/xml/website_set.xml";
    protected string CustomerCodeXmlPath = "/cn/xml/customer_code.txt";
    protected string CustomerServiceXmlPath = "/cn/xml/customer_service.xml";

    // Methods
    protected StringBuilder ArticleTypeBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            builder.AppendLine("<div class=\"footer\">");
            string parentId = BaseFactory.theArticleType.GetArticleTypeByTypeNameAndParentId("帮助中心", "00000000-0000-0000-0000-000000000000");
            string articleTypeId = BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("新手指南", parentId, 1);
            DataTable atricleByArticleTypeIdAndTop = BaseFactory.theArticle.GetAtricleByArticleTypeIdAndTop(articleTypeId, 5);
            builder.AppendLine("<dl>");
            builder.AppendLine("<dt>新手指南</dt>");
            foreach (DataRow row in atricleByArticleTypeIdAndTop.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<dd><a href=\"/cn/help_center/help_detail.html?id=", row["id"], "\">", row["articleTilte"], "</a></dd>" }));
            }
            builder.AppendLine("</dl>");
            string str3 = BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("配送说明", parentId, 1);
            DataTable table2 = BaseFactory.theArticle.GetAtricleByArticleTypeIdAndTop(str3, 5);
            builder.AppendLine("<dl>");
            builder.AppendLine("<dt>配送说明</dt>");
            foreach (DataRow row in table2.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<dd><a href=\"/cn/help_center/help_detail.html?id=", row["id"], "\">", row["articleTilte"], "</a></dd>" }));
            }
            builder.AppendLine("</dl>");
            string str4 = BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("如何付款/退款", parentId, 1);
            DataTable table3 = BaseFactory.theArticle.GetAtricleByArticleTypeIdAndTop(str4, 5);
            builder.AppendLine("<dl>");
            builder.AppendLine("<dt>如何付款/退款</dt>");
            foreach (DataRow row in table3.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<dd><a href=\"/cn/help_center/help_detail.html?id=", row["id"], "\">", row["articleTilte"], "</a></dd>" }));
            }
            builder.AppendLine("</dl>");
            string str5 = BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("售后服务", parentId, 1);
            DataTable table4 = BaseFactory.theArticle.GetAtricleByArticleTypeIdAndTop(str5, 5);
            builder.AppendLine("<dl>");
            builder.AppendLine("<dt>售后服务</dt>");
            foreach (DataRow row in table4.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<dd><a href=\"/cn/help_center/help_detail.html?id=", row["id"], "\">", row["articleTilte"], "</a></dd>" }));
            }
            builder.AppendLine("</dl>");
            string str6 = BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("帮助中心", parentId, 1);
            DataTable table5 = BaseFactory.theArticle.GetAtricleByArticleTypeIdAndTop(str6, 5);
            builder.AppendLine("<dl class=\"dllast\">");
            builder.AppendLine("<dt>帮助中心</dt>");
            foreach (DataRow row in table5.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<dd><a href=\"/cn/help_center/help_detail.html?id=", row["id"], "\">", row["articleTilte"], "</a></dd>" }));
            }
            builder.AppendLine("</dl>");
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.basicSetXmlPath));
            XmlElement element = (XmlElement)document.SelectSingleNode("set/copyright");
            XmlElement element2 = (XmlElement)document.SelectSingleNode("set/domain_web_site");
            XmlElement element3 = (XmlElement)document.SelectSingleNode("set/cn_enterprise_name");
            XmlElement element4 = (XmlElement)document.SelectSingleNode("set/icp_record_number");
            builder.AppendLine("<p class=\"copyright\">" + element.GetAttribute("value") + " " + element2.GetAttribute("value") + " " + element3.GetAttribute("value") + " All Rights Reserved " + element4.GetAttribute("value") + "Powered by <a target=\"_blank\" href=\"http://www.micronet.com.cn/\">Micronet</a></p><img src=\"/cn/advertising/PageBottomFreight.jpg\" />");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder CustomerCodeBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            builder.AppendLine(File.ReadAllText(base.Server.MapPath(this.CustomerCodeXmlPath)));
        }
        catch
        {
        }
        return builder;
    }

    string _customerServerTitle = "";

    public string CustomerServerTitle
    {
        get { return _customerServerTitle; }
       
    }
    string _customerInline = "display:block;";

    public string CustomerInline
    {
        get { return _customerInline; }

    }

    protected StringBuilder CustomerServiceBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.CustomerServiceXmlPath));
            XmlElement element = (XmlElement)document.SelectSingleNode("CustomerService");
            if (!(element.GetAttribute("isShow") == "true"))
            {
                _customerInline = "display:none;";
                return builder;
            }

            _customerServerTitle = element.GetAttribute("title");
   
            DataTable customerService = BaseFactory.theCustomerService.GetCustomerServiceByCompanyId(1);
            foreach (DataRow row in customerService.Rows)
            {
                switch (Convert.ToInt32(row["customerServiceType"]))
                {
                    case 0:
                        builder.AppendLine(string.Concat(new object[] { "<dd><a target=\"_blank\" href=\"http://wpa.qq.com/msgrd?v=3&uin=", row["customerServiceNo"], "&site=qq&menu=yes\"><img style=\"width:18px; height:18px;\" src=\"http://wpa.qq.com/pa?p=2:", row["customerServiceNo"], ":45\" alt=\"", row["title"], "\" title=\"", row["title"], "\">&nbsp;&nbsp;&nbsp;", row["title"], "</a></dd>" }));
                        break;
                    case 1:
                        builder.AppendLine(string.Concat(new object[] { "<dd><a target=\"_blank\" href='msnim:chat?contact=", row["customerServiceNo"], "'><img style=\"border:solid 1px #c0c0c0;\" src='http://messenger.services.live.com/users/", row["customerServiceNo"], "/presenceimage?mkt=zh-cn' />&nbsp;&nbsp;&nbsp;", row["title"], "</a></dd>" }));
                        break;

                    case 2:
                        builder.AppendLine(string.Concat(new object[] { "<dd><a target=\"_blank\" href='http://amos.im.alisoft.com/msg.aw?v=2&uid=", HttpUtility.UrlEncode(row["customerServiceNo"].ToString()), "&site=cntaobao&s=2&charset=utf-8' ><img style=\"border:solid 1px #c0c0c0;\" src='http://amos.im.alisoft.com/online.aw?v=2&uid=", HttpUtility.UrlEncode(row["customerServiceNo"].ToString()), "&site=cntaobao&s=2&charset=utf-8' alt=\"", row["title"], "\" />&nbsp;&nbsp;&nbsp;", row["title"], "</a></dd>" }));
                        break;

                    case 3:
                        builder.AppendLine(string.Concat(new object[] { "<dd><a target=\"_blank\" href='skype:", row["customerServiceNo"], "?call'><img style=\"border:solid 1px #c0c0c0;\" src='http://mystatus.skype.com/smallicon/", row["customerServiceNo"], "' />&nbsp;&nbsp;&nbsp;", row["title"], "</a></dd>" }));
                        break;
                }
            }
   
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}